<?php

namespace app\controllers;

use app\models\UserPlatform;
use h5\components\H5Controller;
use yii;
use yii\authclient\OAuth2;
use yii\helpers\ArrayHelper;

class OauthController extends H5Controller {

    public function beforeAction($action) {
        return parent::beforeAction($action);
    }

    public function actions() {
        return [
            'qq' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
                'authclient' => 'qq',
            ],
            'weixin' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
                'authclient' => 'weixin',
            ],
            'weibo' => [
                'class' => 'yii\authclient\AuthAction',
                'successCallback' => [$this, 'successCallback'],
                'authclient' => 'weibo',
            ],
        ];
    }

    public function successCallback(OAuth2 $client) {
        print_r($client->getUserAttributes());
    }
}